<?php
/**
 * Created by PhpStorm.
 * User: wangxin
 * Date: 17-05-15
 */

namespace backend\service;

use backend\models\CacheList;
use yii\db\Query ;
use yii\data\Pagination ;

class CacheListService
{
    /**
     * 查找banner列表
     * @param int $limit
     */
    public static function findCacheList(){
        $limit = 20;
        $query = new Query();

        $query->select('*')
                ->from(CacheList::tableName())
                ->orderBy('id DESC');


        $pages = new Pagination(['totalCount' => $query->count(), 'defaultPageSize' => $limit]);

        $query->offset($pages->offset)
                ->limit($limit);

        $dataList = $query->all();

        return ["list" => $dataList, "page" => $pages];
    }

}